package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 新生儿满月随访第二页
 * 
 * 
 * @author sunping
 */
public class ManYueVisitSecondActivity extends AbstractControlActivity
		implements OnClickListener {

	// 创建日期ID
	private String createDate;
	private int[] gouloubing = { R.id.check_gouloubing_wu,
			R.id.check_gouloubing_lgrh, R.id.check_gouloubing_fl,
			R.id.check_gouloubing_zt };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_manyue_visit_second);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addRadioGroupView(R.id.rad_kouqiang, "口腔");
		addRadioGroupView(R.id.rad_xinfei, "心肺");
		addRadioGroupView(R.id.rad_fubu, "腹部");
		addRadioEditUnionView(new int[] { R.id.edt_jidai_qt }, "脐部",
				new String[] { "脐部其他" }, R.id.rad_jidai, "其他");
		addRadioGroupView(R.id.rad_sizhi, "四肢");
		addCheckBoxView(gouloubing, "可疑佝偻病体征");
		addRadioGroupView(R.id.rad_waishengzhiqi, "肛门/外生殖器");
		addEditTextView(R.id.edt_xuehongdanbai, "血红蛋白值");
		addEditTextView(R.id.edt_huwaihuodong, "户外活动");
		addEditTextView(R.id.edt_weishengsu, "服用维生素D");
		addRadioGroupView(R.id.rad_fayupinggu, "发育评估");
		addRadioGroupView(R.id.rad_huanbingqingkuang, "两次随访间患病情况");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(ChanQianVisitFirstActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();

		setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_next:
			controlManager.toProperties();
			intent.setClass(this, ManYueVisitThirdActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_previous:
			controlManager.toProperties();
			intent.setClass(this, ManYueVisitFirstActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}
}